<template>
	<view class="content">
		<view class="topBox">
			<view class="fs21 C333 tac lh80">
				请输入您的手机号码及短信验证码
			</view>
			
			<view class="inputLine2">
				<input style="text-align: left;padding-left: 15upx;" v-model="telPhone" class="fs18 C999" placeholder="在此输入您的手机号码" maxlength="11" type="number" value="" />
				<text @click="getCode()" style="background-color: #ff4300;color: #FFFFFF;" v-if="!isget" class="fs18 C333">{{getCode1}}</text>
				<text v-if="isget" class="fs18 C333">{{getCode1}}</text>
			</view>
			
			
			<input class="fs18 C999 input2" v-model="vcode" placeholder="在此输入您的短信校验码" type="text" value="" />
			<button @click="bangdingTel()" class="redBtn">
				立即绑定
			</button>
		</view>
		
		<view class="title fs22 C999 bold">
			 操作提示
		</view>
		
		<view class="titleB fs18 C999">
			1.绑定手机后可直接通过短信接受安全验证等重要操作。		</view>
		
		<view class="titleB fs18 C999">
			2.更改手机时，请通过安全验证后重新输入新手机号绑定。		</view>
		
		<view class="titleB fs18 C999">			3.收到安全验证码后，请在30分钟内完成验证。
		</view>
	
		
	</view>
</template>

<script>
	export default {
		data(){
			return{
				"vcode":"",
				telPhone:"",
				isget:false,
				time:60,
				getCode1:"获取验证码",
				iscode:true
			}
		},
		onLoad() {
			this.GetInfo();
		},
		onShow(){
			
		},
		methods:{
			GetInfo(){//获取用户信息
				let that = this;
				this.$util.request({
						url: '/mobile/index.php?act=member_security&op=member',
						method: 'POST',
						data: {},
					}).then(function(res) {
						console.log(res)
					})
			},
			
			
			bangdingTel(){
				let that = this;				
				this.$util.request({
					url: '/mobile/index.php?act=member_security&op=modify_mobile',
					method: 'post',
					data: {
						"mobile":that.telPhone,
						"vcode":that.vcode
					},
				}).then(function(res) {
					console.log(res)
					if(res.error_code == 0){
						uni.showToast({
							title:"绑定成功",
							icon:"success",
							success() {
								setTimeout(()=>{
									uni.navigateBack(2)
								},1000)
							}
						})
					}else{
						uni.showToast({
							title:"绑定失败，请确认信息"						
						})
					}		
				})
			},
			getCode(){
				var that=this
				if(!(/^1[3456789]\d{9}$/.test(that.telPhone))){
					  uni.showToast({
					  	title:"手机号码有误，请重填",
						icon:"none"
					  }) 
					  return false; 
				} 
				that.isget=true;	
					if(this.iscode){
						that.iscode=false
						this.$util.request({
							url: '/mobile/index.php?act=member_security&op=send_modify_mobile',
							method: 'get',
							data: {
								"mobile":that.telPhone
							},
						}).then(function(res) {
							if(res.error_code==0){
								var codesetInterval = setInterval(() => {
									that.time--;
									that.getCode1 = that.time + "s"
									if (that.time <= 0) {
										clearInterval(codesetInterval);		
										that.time=60;
										that.getCode1="获取验证码"
										that.isget = false;
										that.iscode=true
									}
								}, 1000)
							}else{
								that.isget = false;
								that.iscode=true
								uni.showToast({
									title:res.message,
									icon:"none"
								})
							}
						
						})
					}
			}
		}
	}
</script>

<style>
	.titleNview-placing {
		height: var(--status-bar-height);
		box-sizing: content-box;
	 }
	uni-page-body {
		background-color: #FFFFFF;
		color: rgb(102, 102, 102);
	}
	.titleNview-placing {
		height: var(--status-bar-height);
		box-sizing: content-box;
	 }
	.lh20{
		line-height: 20upx;
		height: 20upx;
	}
	.lh25{
		line-height: 25upx;
	}
	.lh30{
		line-height: 30upx;
	}
	.lh35{
		line-height: 35upx;
	}
	.lh40{
		line-height: 40upx;
	}
	.lh45{
		line-height: 45upx;
	}
	.lh50{
		line-height: 50upx;
	}
	.lh80{
		line-height: 80upx;
	}
	.C000{
		color: #000000;
	}
	.Ce13d97{
		color: #ff4300;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.Cc06{
		color: #ff4300;
	}
	.mt55mb30{
		margin-top: 55upx;
		margin-bottom: 30upx;
	}
	.Cfff{
		color: #FFFFFF;
	}
	
	.flex{		
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-content: space-between;
	}
	.paddingL20{
		padding-left: 20upx;
	}
	.C999{
		color:#999 ;
	}
	.Cff0101{
		color:#ff0101 ;
	}
	.Cc00251{
		color: #c00251;
	}
	.strick{
		text-decoration: line-through;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.line1{
		width: 430upx;
	}
	.hide{
		display: none;
	}
	.marginB20{
		margin-bottom: 20upx;
	}
	
	.twoline{
	   overflow : hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	.pl20{
		padding-left: 20upx;
	}
	.positionT{
		position: relative;
		top: 50upx;
	}
	.paddingB15{
		padding-bottom: 15upx;
	}
	.borderB{
		border-bottom: 1px solid #f4f4f6;
	}
	.borderT{
		border-top: 1px solid #f4f4f6;
	}
	.gl{
		position: absolute;
		right: 30upx;
	}
	.pr30{
		padding-right: 30upx;
	}
	.C333{
		color: #333333;
	}
	.C666{
		color: #666666;
	}
	.Cf00{
		color: #ff0000;
	}
	
	.bold{
		font-weight: bold;
	}
	.C1d1d1d{
		color:#1d1d1d ;
	}
	.fl{
		float: left;
	}
	.fr{
		float: right;
	}
	.tac{
		text-align: center;
	}
	.Ce5258e{
		color: #e5258e;
	}
	.Cccc{
		color: #CCCCCC;
	}
	uni-page-body {
		background-color: #FFFFFF;
		color: rgb(102, 102, 102);
	}		
	.fs30{
		/* font-size: 30upx */
		font-size: 45upx
	}
	.fs26{
		font-size:39upx
		/* font-size: 26upx */
	}
	.fs12{
		font-size: 18upx
		/* font-size: 12upx */
	}
	.fs16{
		font-size: 24upx
		/* font-size: 16upx */
	}
	.fs14{
		font-size: 21upx
		/* font-size: 14upx */
	}
	.fs15{
		font-size: 22.5upx
		/* font-size: 15upx */
	}
	.fs27{
		font-size: 40.5upx
		/* font-size: 27upx */
	}
	.fs18{
		font-size: 27upx
		/* font-size: 18upx */
	}
	.fs28{
		font-size: 42upx
		/* font-size: 28upx */
	}
	.fs10{
		font-size: 15upx
		/* font-size: 10upx */
	}
	.fs30{
		font-size: 45upx
		/* font-size: 28upx */
	}
	.fs24{
		font-size: 36upx
		/* font-size: 24upx */
	}
	.fs20{
		font-size:30upx
		/* font-size: 20upx */
	}
	.fs22{
		font-size:33upx
		/* font-size: 22upx */
	}
	.fs21{
		font-size: 31.5upx
		/* font-size: 21upx */
	}	
	.flexsb{
		display: flex;
		justify-content: space-between;
	}
	.plr20{
		padding: 0 20upx;
	}
	.plr10{
		padding: 0 10upx;
	}
	.content{
		background-color: #f6f4f5;
		min-height: 100vh;
	}
	.topBox{
		box-sizing: border-box;
		padding-top: 30upx;
		text-align: center;
		width: 676upx;
		height: 423upx;
		background-color: #fff;
		border-radius: 10upx;
		margin:32upx auto 60upx ;
	}
	.inputLine2{
		box-sizing: border-box;
		margin-bottom: 10upx;
		display: inline-block;
		position: relative;
		box-sizing: border-box;
		width: 590upx;
		height: 70upx;
		line-height: 70upx;
	}
	.inputLine2 input{
		position: absolute;
		left: 0;
		top: 0;
		border: 1upx solid #bebebe;
		display: inline-block;
		box-sizing: border-box;
		width: 330upx;
		height: 70upx;
		line-height: 70upx;
	}
	.inputLine2 text{
		position: absolute;
		right: 0;
		top: 0;
		box-sizing: border-box;
		background-color: #d7d7d7;
		display: inline-block;
		width: 260upx;
		height: 70upx;
		line-height: 70upx;
	}
	.topBox .input2{
		box-sizing: border-box;
		text-align: left;
		padding-left: 15upx;
		display: inline-block;
		width: 590upx;
		height: 70upx;
		line-height: 70upx;
		border: 1upx solid #bebebe;
		margin: 20upx auto;
		outline: none;
	}
	.topBox .redBtn{
		display: inline-block;
		width: 590upx;
		height: 70upx;
		line-height: 70upx;
		background-color: #ff4300;
		color: #FFFFFF;		
	}
	.title{
		padding-left: 30upx;
		line-height: 50upx;
	}
	.titleB{
		padding:10upx 30upx;
	}
</style>
